class ScanTarget < ActiveRecord::Base
  DISPOSITION_NAMES = {
    1 => :exclude,
    2 => :include_recurse,
    3 => :include_no_recurse,
  }
  DISPOSITION_NUMBERS = DISPOSITION_NAMES.invert
  
  belongs_to :folder
  validates_numericality_of :disposition_id, :only_integer => true
  validates_presence_of :folder_id, :disposition_id
  validates_uniqueness_of :folder_id, :scope => [:disposition_id]
  
  validate :valid_disposition
  
  def valid_disposition
    errors.add_to_base("disposition_id must be a valid integer key into DISPOSITION_NAMES array") if DISPOSITION_NAMES[self.disposition_id].blank?
  end
end
